<template>
    <div>
        <el-row>
            <el-col :span="18">
                <el-form :model="ruleForm" label-width="100px" class="demo-ruleForm">
                    <el-form-item label="标题">
                        <el-input v-model="ruleForm.title"></el-input>
                    </el-form-item>
                    <el-form-item label="内容">
                        <el-input v-model="ruleForm.article"></el-input>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" :loading="loading" @click.native="submit(ruleForm)">新增</el-button>
                    </el-form-item>
                </el-form>
            </el-col>
        </el-row>
    </div>
</template>
<script>
import { articleAdd } from '../api/api'
export default {
    data() {
        return {
            loading: false,
            ruleForm: {
                title: '',
                article: ''
            },
        }
    },
    methods: {
        submit(ruleForm) {
            let user = sessionStorage.getItem('username')
            console.log(user)
            let param = Object.assign(ruleForm, { username: user })
            articleAdd(ruleForm).then((res) => {
                console.log(res)
            })
        }
    }
}
</script>
